[id].vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. <template>
  2. <div>
  3. <!-- 页面头部 -->
  4. <!-- <HomePageHead></HomePageHead>
  5. <HomePageNavigation1></HomePageNavigation1> -->
  6. <!-- 头部 -->
  7. <templateHead v-if="skinId <= 4"></templateHead>
  8. <!-- 皮肤5头部 -->
  9. <templateHead5 v-if="skinId == 5"></templateHead5>
  10. <!-- 菜单 -->
  11. <templateMenu v-if="skinId <= 4"></templateMenu>
  12. <!-- 皮肤5菜单 -->
  13. <templateMenu5 v-if="skinId == 5"></templateMenu5>
  14. <!-- 商圈详情 -->
  15. <div class="topicInfoBox">
  16. <div class="inner">
  17. <!-- 详情头部 -->
  18. <div class="infoHead">
  19. <div class="left">
  20. <div class="userInfo left">
  21. <el-badge value="楼主" class="item" type="warning">
  22. <img v-if='dataInfo.avatar' :src="dataInfo.avatar" alt="">
  23. <img v-else src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png'
  24. alt="">
  25. </el-badge>
  26. <span>{{ dataInfo.nickname }}</span>
  27. </div>
  28. <div class="headContent left">
  29. <h2>{{ dataInfo.title }}</h2>
  30. <p v-show="dataInfo.group_name">
  31. 群聊:
  32. <span>{{ dataInfo.group_name }}</span>
  33. <button @click="joinGroup">加入群聊</button>
  34. </p>
  35. </div>
  36. </div>
  37. <div class="right">
  38. <div class="one">
  39. <span v-for="item in typeList" :key="index">
  40. <span v-if="dataInfo.type == item.value" class="one">{{ item.label }}</span>
  41. </span>
  42. </div>
  43. <p>{{ dataInfo.updated_at }}</p>
  44. </div>
  45. </div>
  46. <!-- 详情页 文本+图片 -->
  47. <div class="infoContent" v-show="dataInfo.content">
  48. <div v-html="dataInfo.content"></div>
  49. </div>
  50. <div class="infoContent1" v-show="!dataInfo.content">
  51. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Document_empty.png" alt="">
  52. <span>可以看看大家的互动哦~</span>
  53. </div>
  54. <!-- 详情页评论 -->
  55. <div class="comment">
  56. <h3>评论</h3>
  57. <div class="commentList" v-for="item in replyList" v-show="page_total != 0">
  58. <div class="left">
  59. <img v-if='item.avatar' :src="item.avatar" alt="">
  60. <img v-else src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png' alt="">
  61. <span class="name">{{ item.nickname }} : </span>
  62. </div>
  63. <div class="center">
  64. <span class="context">{{ item.content }}</span>
  65. </div>
  66. <div class="right">
  67. <span class="time">{{ item.created_at }}</span>
  68. <!-- <span>回复</span> -->
  69. </div>
  70. </div>
  71. <div class="comment_empty" v-show="page_total == 0">
  72. <img src="../../public/topic/message_empty.png" alt="">
  73. <span>暂无评论</span>
  74. </div>
  75. </div>
  76. <!-- 分页 -->
  77. <div class="paginationBox" v-show="page_total != 0">
  78. <el-pagination background layout="prev, pager, next" :total="page_total" prev-text="上一页"
  79. next-text="下一页" :default-page-size="pageSize" @change="changePage" />
  80. </div>
  81. </div>
  82. </div>
  83. <div class="message">
  84. <div class="inner">
  85. <input v-model="content" placeholder="快来回复吧~" type="text" class="messageInput">
  86. <button class="btn" @click="addReply">确定</button>
  87. </div>
  88. </div>
  89. <!-- 页面底部 -->
  90. <!-- <HomeFoot1></HomeFoot1> -->
  91. <templateFoot v-if="skinId <= 4"></templateFoot>
  92. <!-- 皮肤5底部 -->
  93. <templateFoot1 v-if="skinId == 5"></templateFoot1>
  94. </div>
  95. </template>
  96. <script setup>
  97. //1.引用模块 start ---------------------------------------->
  98. //使用ref和reactive动态变量
  99. import { ref, reactive, onMounted } from 'vue'
  100. import { useRoute } from 'vue-router';
  101. //使用官方ssr请求模块
  102. import { useNuxtApp, useFetch } from '#app'
  103. //使用element-plus组件
  104. import { ElPagination, ElBadge, ElInput, ElMessage, ElMessageBox } from 'element-plus';
  105. // axios请求
  106. const nuxtApp = useNuxtApp();
  107. const axios = nuxtApp.$axios;
  108. const { $webUrl, $CwebUrl, $BwebUrl } = useNuxtApp()
  109. //1.引用模块 end ---------------------------------------->
  110. // 定义响应式数据
  111. const seoData = ref({
  112. title: '商圈',
  113. description: '默认描述',
  114. keywords: '默认关键词',
  115. image: 'https://example.com/default-image.jpg'
  116. });
  117. // 在 onMounted 钩子中获取数据
  118. onMounted(() => {
  119. seoData.value.title = '商圈';
  120. seoData.value.description = '默认描述';
  121. seoData.value.keywords = '默认关键词';
  122. })
  123. //2.页面数据 start ---------------------------------------->
  124. const dataInfo = ref({})
  125. const groupId = useState("groupId", () => '')
  126. const replyList = useState("replyList", () => []) //评论列表
  127. //分页
  128. const page = ref(1)
  129. const pageSize = ref(5)
  130. let page_total = ref(0)
  131. const content = ref('')
  132. //2.页面数据 end ---------------------------------------->
  133. //3.获取商圈详情 start ---------------------------------------->
  134. const route = useRoute();
  135. const id = route.params.id; // 获取传递的 id 参数
  136. //页码发生改变
  137. const changePage = (val) => {
  138. console.log(val);
  139. page.value = val
  140. getTopicReply()
  141. }
  142. // 商圈信息
  143. const getTopicInfo = () => {
  144. let data = new FormData()
  145. data.append('id', id)
  146. axios.post('chat/getTopicInfo', data).then(res => {
  147. console.log('商圈信息', res);
  148. dataInfo.value = res.data
  149. groupId.value = res.data.group_id
  150. console.log(groupId.value);
  151. })
  152. }
  153. // 回复商圈 列表
  154. const getTopicReply = () => {
  155. let data = new FormData()
  156. data.append('id', id)
  157. data.append('page', page.value)
  158. data.append('page_size', pageSize.value)
  159. axios.post('chat/getTopicReply', data).then(res => {
  160. console.log('回复商圈列表 ', res);
  161. replyList.value = res.data.data
  162. // page_total.value = res.data.total
  163. page_total.value = res.data.total
  164. console.log("replyList", replyList);
  165. })
  166. }
  167. //5.获取分类和状态 start ---------------------------------------->
  168. const listData = useState("listData", () => [])//商圈列表
  169. const typeList = useState("typeList", () => [])//商圈分类
  170. const topicType = () => {
  171. axios.post('/chat/topicType').then(response => {
  172. console.log(111222333)
  173. console.log(response.data);
  174. // console.log(1);
  175. typeList.value = response.data;
  176. })
  177. }
  178. const topicStatus = () => {
  179. axios.post('chat/topicStatus').then(response => {
  180. console.log(response);
  181. })
  182. }
  183. onMounted(() => {
  184. getTopicInfo(); //商圈信息
  185. getTopicReply(); //回复商圈列表
  186. topicType();
  187. topicStatus();
  188. })
  189. //加入群聊
  190. const joinGroup = () => {
  191. ElMessageBox.confirm(
  192. '加入群聊后,页面跳转至后台群聊页面',
  193. '是否加入群聊?',
  194. {
  195. confirmButtonText: '是',
  196. cancelButtonText: '否',
  197. center: true,
  198. }
  199. ).then(() => {
  200. console.log('groupId.value', groupId.value);
  201. let data = new FormData()
  202. data.append('group_id', groupId.value)
  203. axios.post('chat/joinGroup', data).then(res => {
  204. console.log('加入群聊 ', res);
  205. if (res.code == 0 && res.message !== '已加入群') {
  206. ElMessage.error(res.message)
  207. } else if (res.code == 0 && res.message == '已加入群') {
  208. ElMessage({
  209. message: res.message,
  210. type: 'success',
  211. })
  212. setTimeout(() => {
  213. // window.open($BwebUrl + '/#/hall?userurl=' + $webUrl, '_blank');
  214. window.open($BwebUrl + '/#/businessDistrict?userurl=' + $webUrl, '_blank');
  215. //window.open('http://admindev.bjzxtw.org.cn/#/hall', '_blank');
  216. }, 1000)
  217. } else if (res.code == 200) {
  218. ElMessage({
  219. message: '加入成功',
  220. type: 'success',
  221. })
  222. setTimeout(() => {
  223. // window.open($BwebUrl + '/#/hall?userurl=' + $webUrl, '_blank');
  224. window.open($BwebUrl + '/#/businessDistrict?userurl=' + $webUrl, '_blank');
  225. //window.open('http://admindev.bjzxtw.org.cn/#/hall', '_blank');
  226. }, 1000)
  227. }
  228. })
  229. }).catch(() => {
  230. ElMessage({
  231. type: 'error',
  232. message: '已取消',
  233. })
  234. })
  235. }
  236. // 回复商圈
  237. const addReply = () => {
  238. let data = new FormData()
  239. data.append('id', id)
  240. data.append('content', content.value)
  241. axios.post('chat/addReply', data).then(res => {
  242. console.log('回复商圈 ', res);
  243. if (res.code == 0) {
  244. ElMessage.error(res.message)
  245. getTopicReply();
  246. } else if (res.code == 200) {
  247. ElMessage({
  248. message: '回复成功',
  249. type: 'success',
  250. })
  251. content.value = ''
  252. getTopicReply();
  253. }
  254. })
  255. }
  256. //3.获取商圈详情 end ---------------------------------------->
  257. //自助建站 start---------------------------------------->
  258. //1.获得自助建站头部底部
  259. import templateHead from '@/components/template/sector/head/1200x200/1.vue'
  260. import templateHead5 from '@/components/template/sector/head/1200x250/1.vue'
  261. import templateMenu from '@/components/template/sector/menu/1200x130/1.vue'
  262. import templateMenu5 from '@/components/template/sector/menu/1200x187/1.vue'
  263. import templateFoot from '@/components/template/sector/foot/1200x580/1.vue'
  264. import templateFoot1 from '@/components/template/sector/foot/1200x680/1.vue'
  265. //2.获得pinia源
  266. import { useTemplateBaseStore } from '@/stores/templateBase'
  267. const templateBaseStore = useTemplateBaseStore()
  268. //3.获得该页的皮肤id
  269. const skinId = ref("")
  270. const websiteId = ref("")
  271. //4.获得站点基本信息
  272. const responseStatus = await requestDataPromise('/web/getWebsiteAllinfo', {
  273. method: 'GET',
  274. query: {
  275. 'link_textnum': 24,
  276. 'link_imgnum': 18,
  277. 'link_footnum': 4
  278. },
  279. });
  280. if (responseStatus.code == 200) {
  281. if (responseStatus.data.website_foot.foot_info.status == 1) {
  282. //网站模板已停用,直接转入404页面
  283. navigateTo('/error?findPage=index')
  284. } else {
  285. //4.1设置站点基本信息
  286. templateBaseStore.setWebSiteInfo(responseStatus.data)
  287. websiteId.value = responseStatus.data.website_head.id;
  288. //4.2设置皮肤id
  289. skinId.value = templateBaseStore.webSiteInfo.website_foot.foot_info.template_id;
  290. //4.3设置seo
  291. useSeoMeta({
  292. title: "商圈" + "_" + "三农资讯网_全国政务信息一体化应用平台",
  293. meta: [
  294. { name: 'description', content: "三农资讯网以服务于党和国家各级职能部门三农政务资讯发布及政务公开信息公示为基点,为全国县级以上各级党政机关及其职能部门配置各自公开独立网络发布平台。主要频道有:三农政务资讯,农科资讯,农资购销,农产购销,农贸资讯,三农致富信息,农村文化生活,三农政策法规,三农之窗,三农调查,三农服务,三农知识,农民工,打假维权等。三农资讯网打造最具影响力的三农信息发布平台,并成为最具权威的三农资讯网。_三农资讯网-测试专用_全国政务信息一体化应用平台", tagPriority: 10 },
  295. { name: 'keywords', content: "三农资讯,农业,三农,三农在线,农业新闻,三农资讯网_三农资讯网-测试专用_全国政务信息一体化应用平台", tagPriority: 10 }
  296. ]
  297. });
  298. }
  299. }
  300. //5.获得广告池
  301. const adData = ref([]);
  302. const adResponseStatus = await requestDataPromise('/web/getWebsiteAdvertisement', {
  303. method: 'GET',
  304. query: {},
  305. });
  306. if (adResponseStatus.code == 200) {
  307. templateBaseStore.setAdList(adResponseStatus.data)
  308. adData.value = adResponseStatus.data;
  309. }
  310. //6.是否使用了搜索页
  311. const response = await requestDataPromise('/client/indexData', {
  312. method: 'POST',
  313. body: {
  314. 'website_id': websiteId.value,
  315. 'getpage': 'article'
  316. },
  317. });
  318. if (response.code == 200) {
  319. //是否启用搜索功能
  320. templateBaseStore.setIsSearch(response.data.isSearch)
  321. }
  322. //自助建站 end---------------------------------------->
  323. </script>
  324. <style lang="less" scoped>
  325. .topicInfoBox {
  326. .inner {
  327. width: 1200px;
  328. margin: 0 auto;
  329. //信息头部
  330. .infoHead {
  331. height: 200px;
  332. padding: 65px 0 60px 40px;
  333. border-bottom: 1px solid rgba(0, 0, 0, 0.10);
  334. box-sizing: border-box;
  335. >.left {
  336. .userInfo {
  337. margin-right: 90px;
  338. .item {
  339. margin-top: -5px;
  340. margin-right: -5px;
  341. :deep(.el-badge__content.is-fixed) {
  342. position: absolute;
  343. right: calc(1px + var(--el-badge-size) / 2);
  344. top: 0;
  345. transform: translateY(-31%) translateX(79%);
  346. z-index: var(--el-index-normal);
  347. }
  348. img {
  349. width: 66px;
  350. height: 66px;
  351. vertical-align: middle;
  352. border-radius: 50%;
  353. }
  354. }
  355. span {
  356. margin-left: 15px;
  357. font-family: Microsoft YaHei, Microsoft YaHei;
  358. font-weight: 400;
  359. font-size: 18px;
  360. color: #333333;
  361. }
  362. }
  363. .headContent {
  364. h2 {
  365. width: 750px;
  366. height: 56px;
  367. line-height: 28px;
  368. display: -webkit-box;
  369. -webkit-box-orient: vertical;
  370. -webkit-line-clamp: 2;
  371. overflow: hidden;
  372. text-overflow: ellipsis;
  373. word-break: break-all;
  374. font-family: Microsoft YaHei, Microsoft YaHei;
  375. font-weight: bold;
  376. font-size: 20px;
  377. color: #333333;
  378. margin-bottom: 26px;
  379. }
  380. >p {
  381. font-family: Microsoft YaHei, Microsoft YaHei;
  382. font-weight: 400;
  383. font-size: 16px;
  384. color: #333333;
  385. button {
  386. width: 86px;
  387. height: 32px;
  388. background-color: #028e21;
  389. color: #fff;
  390. border: none;
  391. margin-left: 100px;
  392. }
  393. }
  394. }
  395. }
  396. >.right {
  397. position: relative;
  398. div {
  399. position: absolute;
  400. right: 0;
  401. top: 0;
  402. width: 71px;
  403. height: 32px;
  404. line-height: 32px;
  405. text-align: center;
  406. background-color: #d9f0d6;
  407. margin-bottom: 29px;
  408. font-family: Microsoft YaHei, Microsoft YaHei;
  409. font-weight: 400;
  410. font-size: 16px;
  411. color: #33B023;
  412. }
  413. .one {
  414. color: #FFAA33;
  415. background-color: #fbebd5;
  416. }
  417. .two {
  418. color: #33B023;
  419. background-color: #d5ecd2;
  420. }
  421. .three {
  422. color: #666;
  423. background-color: #ebebeb;
  424. }
  425. p {
  426. width: 150px;
  427. text-align: right;
  428. position: absolute;
  429. top: 62px;
  430. right: 0;
  431. }
  432. }
  433. }
  434. // 有详情信息
  435. .infoContent {
  436. width: 1196px;
  437. overflow: hidden;
  438. padding: 30px 46px;
  439. font-family: Microsoft YaHei, Microsoft YaHei;
  440. font-size: 20px;
  441. line-height: 40px;
  442. box-sizing: border-box;
  443. div {
  444. word-wrap: break-word;
  445. /* 强制长单词或 URL 换行 */
  446. overflow-wrap: break-word;
  447. /* 现代推荐用法,等同于 word-wrap */
  448. white-space: pre-wrap;
  449. /* 保留空白字符并允许自动换行 */
  450. word-break: break-all;
  451. /* 强制在任意字符处换行 */
  452. }
  453. }
  454. .leftBottom::v-deep p {
  455. width: 1200px;
  456. white-space: pre-wrap;
  457. }
  458. //没有详情信息
  459. .comment_empty,
  460. .infoContent1 {
  461. height: 300px;
  462. line-height: 260px;
  463. text-align: center;
  464. img {
  465. width: 78px;
  466. height: 78px;
  467. vertical-align: -25px;
  468. vertical-align: middle;
  469. margin-right: 20px;
  470. }
  471. span {
  472. font-family: Microsoft YaHei, Microsoft YaHei;
  473. font-weight: bold;
  474. font-size: 26px;
  475. color: #CCCCCC;
  476. }
  477. }
  478. //评论
  479. .comment {
  480. h3 {
  481. height: 100px;
  482. padding-top: 30px;
  483. box-sizing: border-box;
  484. border-bottom: 1px solid #E1E1E1;
  485. font-family: Microsoft YaHei, Microsoft YaHei;
  486. font-weight: 400;
  487. font-size: 22px;
  488. color: #000000;
  489. }
  490. .commentList {
  491. border: 1px solid #E1E1E1;
  492. background-color: #fafafa;
  493. margin-top: 20px;
  494. padding: 30px 30px;
  495. box-sizing: border-box;
  496. display: flex;
  497. align-items: flex-start;
  498. justify-content: space-between;
  499. .left {
  500. width: 400px;
  501. margin-right: 30px;
  502. display: flex;
  503. justify-content: space-between;
  504. img {
  505. width: 52px;
  506. height: 52px;
  507. border-radius: 50%;
  508. vertical-align: middle;
  509. margin-right: 15px;
  510. }
  511. span {
  512. height: 52px;
  513. line-height: 22px;
  514. padding-top: 10px;
  515. }
  516. .name {
  517. width: 120px;
  518. font-family: Microsoft YaHei, Microsoft YaHei;
  519. font-weight: 400;
  520. font-size: 16px;
  521. color: #333333;
  522. margin-right: 15px;
  523. white-space: nowrap;
  524. overflow: hidden;
  525. text-overflow: ellipsis;
  526. display: block;
  527. }
  528. }
  529. .center {
  530. .context {
  531. width: 700px;
  532. margin-right: 40px;
  533. display: -webkit-box;
  534. -webkit-box-orient: vertical;
  535. -webkit-line-clamp: 2;
  536. overflow: hidden;
  537. text-overflow: ellipsis;
  538. word-break: break-all;
  539. font-family: Microsoft YaHei, Microsoft YaHei;
  540. font-weight: bold;
  541. font-size: 16px;
  542. color: #333333;
  543. }
  544. }
  545. .right {
  546. .time {
  547. display: block;
  548. width: 200px;
  549. font-family: Microsoft YaHei, Microsoft YaHei;
  550. font-weight: 400;
  551. font-size: 16px;
  552. color: #999999;
  553. margin-right: 30px;
  554. }
  555. span {
  556. font-family: Microsoft YaHei, Microsoft YaHei;
  557. font-weight: 400;
  558. font-size: 16px;
  559. color: #333333;
  560. }
  561. }
  562. }
  563. }
  564. }
  565. }
  566. //评论回复
  567. .message {
  568. width: 1200px;
  569. margin: 0 auto 20px;
  570. padding: 0px 25px;
  571. box-sizing: border-box;
  572. height: 145px;
  573. line-height: 145px;
  574. background-color: #ecf5ee;
  575. .inner {
  576. .messageInput {
  577. width: 1000px;
  578. height: 67px;
  579. outline: none;
  580. border: 1px solid #E1E1E1;
  581. background-color: #fafafa;
  582. font-family: Microsoft YaHei, Microsoft YaHei;
  583. font-weight: 400;
  584. font-size: 18px;
  585. color: #666;
  586. padding: 0 20px;
  587. box-sizing: border-box;
  588. }
  589. .btn {
  590. width: 115px;
  591. height: 40px;
  592. border: none;
  593. background-color: #028e21;
  594. color: #fff;
  595. border-radius: 6px;
  596. margin-left: 36px;
  597. font-family: Microsoft YaHei, Microsoft YaHei;
  598. font-weight: 400;
  599. font-size: 16px;
  600. }
  601. }
  602. }
  603. //分页
  604. .paginationBox {
  605. display: flex;
  606. justify-content: center;
  607. margin-top: 60px;
  608. margin-bottom: 90px;
  609. // 鼠标移入后字体颜色
  610. :deep(.el-pagination:hover) {
  611. color: #139609;
  612. }
  613. :deep(.el-pagination.is-background .btn-next),
  614. :deep(.el-pagination.is-background .btn-prev) {
  615. width: 70px;
  616. height: 34px;
  617. margin: 0px 10px;
  618. border-radius: 4px;
  619. }
  620. :deep(.el-pagination.is-background .el-pager li) {
  621. margin: 0px 10px;
  622. width: 38px;
  623. height: 34px;
  624. border-radius: 4px;
  625. }
  626. :deep(.el-pagination.is-background .btn-next.is-active),
  627. :deep(.el-pagination.is-background .btn-prev.is-active),
  628. :deep(.el-pagination.is-background .el-pager li.is-active) {
  629. background-color: #028e21;
  630. color: #fff;
  631. }
  632. }
  633. </style>